package com.hspedu.poly_.polyparameter;

/**
 * @Author Stringzhua
 * @Date 2024/3/2 20:27
 * description:
 */
public class PloyParameter {
    public static void main(String[] args) {
        Worker tom = new Worker("tom", 2500);
        Manager milan = new Manager("milan", 5000, 200000);
        PloyParameter ployParameter = new PloyParameter();
        ployParameter.showEmpAnnl(tom);
        ployParameter.showEmpAnnl(milan);

        ployParameter.testWork(tom);
        ployParameter.testWork(milan);
    }
    //showEmpAnnl(Employee e)
    //实现获取任何员工对象的年工资
    public void showEmpAnnl(Employee e){
        System.out.println(e.getAnnual());//动态绑定机制
    }
    public void testWork(Employee e){
        if(e instanceof Worker){
            ((Worker) e).work();//向下转型操作
        }else if (e instanceof Manager){
            ((Manager) e).manage();//向下转型操作
        }else {
            System.out.println("员工有误,不做处理");
        }
    }
}
